package com.ys.service.base.impl;

import com.ys.entity.base.TbUserAttendance;
import com.ys.mapper.base.TbUserAttendanceMapper;
import com.ys.service.base.TbUserAttendanceService;
import com.ys.vo.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 员工考勤信息表
 */
@Service("tbUserAttendanceService")
public class TbUserAttendanceServiceImpl implements TbUserAttendanceService {
	private static final Logger logger = LoggerFactory.getLogger(TbUserAttendanceServiceImpl.class);

	@Autowired
	private TbUserAttendanceMapper tbUserAttendanceMapper;

	/**
	 * 新增
	 */
	@Override
	public R save(TbUserAttendance tbUserAttendance) throws Exception {
		TbUserAttendance hasAdd = new TbUserAttendance()
				.setUserId(tbUserAttendance.getUserId())
				.setAttendanceMonth(tbUserAttendance.getAttendanceMonth()).queryFirst();
		if(hasAdd!=null){//修改
			tbUserAttendance.setId(hasAdd.getId());
			tbUserAttendanceMapper.update(tbUserAttendance);
		}else {//新增
			tbUserAttendance.setStatus(1);
			tbUserAttendanceMapper.insert(tbUserAttendance);
		}
		return R.ok();
	}



}
